
package stackoverflow.domain.question;

import stackoverflow.domain.shared.Entity;
import stackoverflow.domain.shared.IdGenerator;
import stackoverflow.domain.user.User;

public class Post implements Entity<Post>
{
	protected String id = IdGenerator.createId();
	protected User postedBy;
	protected String text;

	public String getId()
	{
		return id;
	}

	public User getPostedBy()
	{
		return postedBy;
	}

	public String getText()
	{
		return text;
	}

	public void editPost(String text)
	{
		this.text = text;
	}

	@Override
	public int hashCode()
	{
		return id.hashCode();
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Post other = (Post) obj;
		return sameIdentityAs(other);
	}

	public boolean sameIdentityAs(Post other)
	{
		return other != null && this.id.equals(other.id);
	}
}
